import SvgIcon from './SvgIcon.vue'
import Pagination from './Pagination.vue'
import Category from './Category.vue'
//引入element-plus提供的全部图标组件注册为全局组件
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { App } from 'vue'

// 显式定义globalComponent的类型
interface GlobalComponents {
  SvgIcon: typeof SvgIcon
  Pagination: typeof Pagination
  Category: typeof Category
}

const globalComponent: GlobalComponents = {
  SvgIcon,
  Pagination,
  Category
}

export default {
  install(app: App) {
    // 注册全局组件
    Object.keys(globalComponent).forEach((key) => {
      app.component(key, globalComponent[key as keyof GlobalComponents])
    })
    // 注册element-plus提供的全部图标组件
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component)
    }
  }
}
